package com.demo.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @EnableAutoConfiguration 是用来启动一个特性的，这个特性可以把配置文件的值注入到Bean里面去
 *                              一般是和@ConfigurationProperties一起使用
 * @EnableAsync 启用异步，一般是和@Async一起使用
 *
 * @Import 用来导入一个多个配置类（会被Spring容器托管），或者配置类（配置类里面的Bean都会被spring容器所托管）
 */
@EnableAutoConfiguration
@EnableAsync
@ComponentScan
//@Import(MyImportSelector.class)
//@EnableLog(name = "My SpringBoot")
@Import(MyImportBeanDefinitionRegistrar.class)
@EnableEcho(packages = {"com.demo.springboot.bean","com.demo.springboot.vo"})
public class App {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
        System.out.println("tomcat:"+context.getBean(TomcatProperty.class));
        context.getBean("timeAsync",Runnable.class).run();
        System.out.println("=====END======");
        System.out.println("User: "+context.getBean(User.class));
        System.out.println("Runnable{}: "+context.getBeansOfType(Runnable.class));
        context.close();
    }
}
